1
'*************************** Module Header ******************************'
2 ' Module Name: MainForm.vb
3 ' Project: VBWebBrowserAutomation
4 ' Copyright (c) Microsoft Corporation.
6 ' This is the main form of this application. It is used to initialize the UI and
9 ' This source is subject to the Microsoft Public License.
10 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 ' All other rights reserved.
13 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 '*************************************************************************'
18 Imports System
.Security
.Permissions
20 Partial
Public Class MainForm
23 <PermissionSetAttribute(SecurityAction
.LinkDemand
, Name
:="FullTrust")>
27 ' Register the events.
28 AddHandler webBrowser
.Navigating
, AddressOf webBrowser_Navigating
29 AddHandler webBrowser
.DocumentCompleted
, AddressOf webBrowser_DocumentCompleted
33 ''' Disable the btnAutoComplete when webBrowser is navigating.
35 Private Sub webBrowser_Navigating(ByVal sender
As Object,
36 ByVal e
As WebBrowserNavigatingEventArgs
)
37 btnAutoComplete
.Enabled
= False
41 ''' Refresh the UI after the web page is loaded.
43 Private Sub webBrowser_DocumentCompleted(ByVal sender
As Object,
44 ByVal e
As WebBrowserDocumentCompletedEventArgs
)
45 btnAutoComplete
.Enabled
= webBrowser
.CanAutoComplete
46 tbUrl
.Text
= e
.Url
.ToString()
50 ''' Handle the Click event of btnAutoComplete_
52 Private Sub btnAutoComplete_Click(ByVal sender
As Object,
53 ByVal e
As EventArgs
) Handles btnAutoComplete
.Click
55 webBrowser
.AutoComplete()
57 MessageBox
.Show(ex
.Message
)
62 ''' Hanle the Click event of the btnGo.
64 Private Sub btnGo_Click(ByVal sender
As System
.Object, ByVal e
As System
.EventArgs
) Handles btnGo
.Click
66 webBrowser
.Navigate(tbUrl
.Text
)
68 MessageBox
.Show(ex
.Message
)